package com.weight.common.handler;

import javax.servlet.http.HttpServletRequest;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.weight.common.exception.CSException;
import com.weight.common.exception.LoginerException;
import com.weight.common.util.JsonResultUtil;

@ControllerAdvice
public class GlobalExceptionHandler {
 
	/**
	 * 针对CSExecption做一个统一异常处理，返回固定的格式JsonResultUtil/JSON  
	 * @param e
	 * @return
	 */
    @ExceptionHandler(value = CSException.class)
    @ResponseBody    
    public JsonResultUtil handlerSellerException(CSException e){
        return new JsonResultUtil(e.getCode(), e.getMessage());
    }
    
    @ExceptionHandler(value = LoginerException.class)
    public ModelAndView handlerAuthorizeException() {
        return new ModelAndView("redirect:".concat("/login"));
    } 
    
    
    
    
    
    
    
}
